package com.bascker.algorithm.practice.sliding_window.easy.contains_near_by_duplicate;

public class Solution1 {

    // 暴力枚举：双重for循环
    // 1 <= n = nums.length
    // 0 <= k
    public boolean containsNearbyDuplicate(int[] nums, int k) {
        int n = nums.length;

        for (int i = 0; i < n; i ++) {
            for (int j = i + 1; j < n; j ++) {
                if (nums[i] == nums[j] && Math.abs(i - j ) <= k) {
                    return true;
                }
            }
        }

        return false;
    }

}
